// functionPage/pages/review/checkIn/checkIn.js
import Http from '../../../../utils/http.js';
const http = new Http();
const app = getApp();

Page({
    /**
     * 页面的初始数据
     */
    data: {
        id: '',
        review: '',
        realName: '',
        phone: '',
        address: '',
        country: '',
        year: '',
        month: '',
        day: '',
        mpdescription: '',
        sceneImageArr: [],
        description: [],
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        console.log(options.id);
        this.setData({
            review: options.review || '',
            id: options.id,
        });
        this.getCheckinDetail(options.id);
    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {},
    // 预览图片
    previewImgDes(e) {
        let index = e.currentTarget.dataset.index;
        this.setData({
            // showPreviewImg: true,
            currentPicIndex: index,
        });
        wx.navigateTo({
            url: `../../../../pages/checkIn/imgPreview/imgPreview?hideBottom=${true}`,
        });
    },
    getCheckinDetail(id) {
        let _that = this;
        let data = {
            authId: app.globalData.authId,
            id,
        };
        http.getRequest('cjMap/getCheckinDetail', data).then((res) => {
            if (res.status == 0) {
                console.log(res.data.realname);
                _that.setData({
                    realName: res.data.realname,
                    phone: res.data.phone,
                    address: res.data.cityname,
                    country: res.data.country,
                    year: res.data.checkintime.substring(0, 4),
                    month: res.data.checkintime.substring(5, 7),
                    day: res.data.checkintime.substring(8, 10),
                    sceneImageArr: res.data.picurl
                        ? JSON.parse(res.data.picurl)
                        : [],
                    description: res.data.picdescription
                        ? JSON.parse(res.data.picdescription)
                        : [],
                    mpdescription: res.data.mpdescription,
                });
            }
        });
    },
});
